﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
		<title>NLayer Architecture</title>
		<link type="text/css" rel="stylesheet" href="bootstrap.min.css" />
		</head>

	<body>

		<div class="document-contents">

			<h3 id="DocIntroLayers">Introduction</h3>
			<p>Layering of an application's codebase is a widely accepted technique to help
reduce complexity and improve code reusability. To achieve layered
architecture, ASP.NET Boilerplate follows the principles of <strong>Domain Driven
Design</strong>.</p>
			<h3>Domain Driven Design Layers</h3>
			<p>There are four fundamental layers in Domain Driven Design (DDD):</p>
			<ul>
				<li>
					<strong>Presentation Layer</strong>: Provides an interface to the user.
	Uses the Application Layer to achieve user interactions.</li>
				<li>
					<strong>Application Layer</strong>: Mediates between the Presentation
	and Domain Layers. Orchestrates business objects to perform specific
	application tasks.</li>
				<li>
					<strong>Domain Layer</strong>: Includes business objects and their rules.
	This is heart of the application.</li>
				<li>
					<strong>Infrastructure Layer</strong>: Provides generic 
					technical capabilities that support higher layers mostly 
					using 3rd-party libraries.</li>
			</ul>
			<h3>ASP.NET Boilerplate Application Architecture Model</h3>
			<p>In addition to DDD, there are also other logical and physical 
			layers in a modern architected application. The model below is 
			suggested and implemented for ASP.NET Boilerplate applications. 
			ASP.NET Boilerplate not only makes to implement this model easier by 
			providing base classes and services, but also provides
			<a href="/Templates">startup templates</a> to directly start with 
			this model.</p>
			<p>
			<a href="https://raw.githubusercontent.com/aspnetboilerplate/aspnetboilerplate/master/doc/WebSite/images/abp-nlayer-architecture.png" target="_blank">
			<img class="img-thumbnail" alt="ASP.NET Boilerplate NLayer Architecture" height="1236" src="images/abp-nlayer-architecture.png" width="1220" /></a></p>
		</div>
		<h4>Client Applications</h4>
		<p>These are remote clients uses the application as a service via HTTP 
		APIs (API Controllers, <a href="OData-Integration.html">OData</a> 
		Controllers, maybe GraphQL endpoint). A remote client can be a SPA, a 
		mobile application or a 3rd-party consumer. <a href="Localization.html">
		Localization</a> and <a href="Navigation.html">Navigation</a> can be 
		done inside this applications. </p>
		<h4>Presentation Layer</h4>
		<p>ASP.NET [Core] MVC (Model-View-Controller) can be considered as the 
		presentation layer. It can be a physical layer (uses application via 
		HTTP APIs) or a logical layer (directly injects and uses
		<a href="Application-Services.html">application services</a>). In either 
		case it can include <a href="Localization.html">Localization</a>,
		<a href="Navigation.html">Navigation</a>,
		<a href="Object-To-Object-Mapping.html">Object Mapping</a>,
		<a href="Caching.html">Caching</a>, <a href="Setting-Management.html">
		Configuration Management</a>, <a href="Audit-Logging.html">Audit Logging</a> 
		and so on. It should also deal with <a href="Authorization.html">
		Authorization</a>, <a href="Abp-Session.html">Session</a>,
		<a href="Feature-Management.html">Features</a> (for
		<a href="Multi-Tenancy.html">multi-tenant</a> applications) and
		<a href="Handling-Exceptions.html">Exception Handling</a>.</p>
		<h4>Distributed Service Layer</h4>
		<p>This layer is used to serve application/domain functionality via 
		remote APIs like REST, OData, GraphQL... They don&#39;t contain business 
		logic but only translates HTTP requests to domain interactions or can 
		use application services to delegate the operation. This layer generally 
		include <a href="Authorization.html">Authorization</a>,
		<a href="Caching.html">Caching</a>,
		<a href="Audit-Logging.html">Audit Logging</a>, <a href="Object-To-Object-Mapping.html">Object Mapping</a>,
		<a href="Handling-Exceptions.html">Exception Handling</a>,
		<a href="Abp-Session.html">Session</a> and so on... </p>
		<h4>Application Layer</h4>
		<p>Application layer mainly includes <a href="Application-Services.html">
		Application Services</a> those use domain layer and domain objects (<a href="Domain-Services.html">Domain 
		Services</a>, <a href="Entities.html">Entities</a>...) to perform 
		requested application functionalities. It uses
		<a href="Data-Transfer-Objects.html">Data Transfer Objects</a> to get 
		data from and to return data to presentation or distributed service 
		layer. It can also deal with <a href="Authorization.html">Authorization</a>,
		<a href="Caching.html">Caching</a>, <a href="Audit-Logging.html">Audit 
		Logging</a>, <a href="Object-To-Object-Mapping.html">Object Mapping</a>,
		<a href="Abp-Session.html">Session</a> and so on...</p>
		<h4>Domain Layer</h4>
		<p>This is the main layer that implements our domain logic. It includes
		<a href="Entities.html">Entities</a>, <a href="Value-Objects.html">Value 
		Objects</a>, <a href="Domain-Services.html">Domain Services</a> to 
		perform business/domain logic. It can also include
		<a href="Specifications.html">Specifications</a> and trigger
		<a href="EventBus-Domain-Events.html">Domain Events</a>. It defines 
		Repository Interfaces to read and persist entities from data source 
		(generally a DBMS).</p>
		<h4>Infrastructure Layer</h4>
		<p>Infrastructure layer makes other layers working: It implements 
		repository interfaces (using <a href="Entity-Framework-Core.html">Entity 
		Framework Core</a> for example) to actually work with a real database, it may 
		include integration to a vendor to <a href="Email-Sending.html">send 
		emails</a> and so on. This is not a strict layer below all layers, but 
		actually supports other layers by implementing 
		abstract concepts of them.</p>
	</body>

</html>
